package buttons;

import processing.core.PApplet;
import buttons.control.C_DropDown;
import buttons.view.V_DropDown;
import buttons.view.V_TextButton;
import view.DisplayList;
import controllers.ControlManager;

/**************************************************
DROP_DOWN_LIST: select an option from a list. 
Feb. 21, 2012: now supports horizontal or vertically aligned drop down.(great for dynamic graphs)
***************************************************/

public class DropDownList extends Button
{
	public DropDownList(DisplayList v, ControlManager c, String n, float xWidth, float yHeight, PApplet p)
	{
	   super(v, c, n, xWidth, yHeight, p); // pass the PApplet to trigger the extra constructor
	   ((V_TextButton)vButton).useFont(p);
	   
	}
	// constructor for buttons that don't move around:
	public DropDownList(DisplayList v, ControlManager c, String n, float xWidth, float yHeight, float xPos, float yPos, PApplet p)
	{
	   super(v, c, n, xWidth, yHeight, xPos, yPos, p); // pass the PApplet to trigger the extra constructor
	   ((V_TextButton)vButton).useFont(p);
	}
	@Override // override special generateButtons(...) method that also contains a PApplet parameter
	protected void generateButtons(DisplayList v, ControlManager c, String n, float xWidth, float yHeight, PApplet p)
	{
	    vButton = new V_DropDown(n, xWidth, yHeight);
	    cButton = new C_DropDown((V_DropDown)vButton, p);
	    addToManagerLists(v, c);
	}
	public void addOption(String item) {
	  ((C_DropDown)cButton).addOption(item);
	}
	public void addOptions(String[] items) {
	  for(int i = 0; i < items.length; i++)
	  {
	    ((C_DropDown)cButton).addOption(items[i]);
	  }
	}
	public boolean isExpanded() {
	  return ((C_DropDown)cButton).isExpanded();
	}
	public void setNameVisible(boolean val)
	{
	  ((V_DropDown)vButton).setShowName(val);
	}
}
